package service.StrategyService._stub;

import VO.StrategyVO;
import service.StrategyService.HotelStrategyService;
import util.Message;
import util.UserType;

import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class HotelStrategyService_stub extends UnicastRemoteObject implements HotelStrategyService {

    private static final long serialVersionUID = 6458517389589305500L;

    public HotelStrategyService_stub() throws RemoteException {
        super();
    }

    public Iterator<StrategyVO> getStrategy(String hotelid) throws RemoteException{
        List<StrategyVO> list= new ArrayList<StrategyVO>();
        StrategyVO strategyVO=new StrategyVO("insomnia",UserType.CLIENT,"1元可住",30);
        list.add(strategyVO);
        Iterator<StrategyVO> iter=list.iterator();
        return  iter;
    }

    public Message addNewStrategy(StrategyVO strategyVO)throws RemoteException {
        StrategyVO newStrategyVO=strategyVO.getStrategyVO();
       if (newStrategyVO.getContent()==null||newStrategyVO.getDiscount()<=0){
            return Message.NOT_COMPLETE;
        }else if(newStrategyVO.getUserType()==UserType.HOTELSTAFF||newStrategyVO.getUserType()==UserType.WEBSITEMARKERER){
            return Message.SUCCESS;
        }else{
            return Message.FAIL;
        }
    }

    public boolean removeStrategy(StrategyVO strategyVO) throws RemoteException{
        if (strategyVO!=null){
            return true;
        }else{
            return false;
        }
    }
}
